home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13379 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.1 KB  |  80 lines

  1. Path: news.interport.net!usenet
  2. From: yaron@interport.net (Adi)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: #include"#include"thing.h""
  5. Date: Mon, 25 Mar 1996 07:35:02 GMT
  6. Organization: Interport Communications Corp.
  7. Message-ID: <4j580f$6ps@park.interport.net>
  8. References: <1996Mar23.150917.1@orion.alaska.edu>
  9. NNTP-Posting-Host: yaron.port.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. axmmm@orion.alaska.edu wrote:
  13.  
  14. >Hello. I have  a question. 
  15.  
  16. >Say I define a THING class. Once I do this, you see, I can create lots of
  17. >things.
  18.  
  19. >But.
  20.  
  21. >Each of these THINGs must contain a list of THINGs. Or so runs the theory.
  22. >I'm placing a bunch of THINGS in a doubly-linked list; but I want each of these
  23. >things to be able to (via a Thing.Search type function) scroll through the list
  24. >and look at all the other things.
  25.  
  26. >So, essentially, I'm handing each Thing, in the list, a copy of the list with
  27. >all the things.
  28.  
  29. >This is causing me problems when I try to compile, since in order to define a
  30. >class THINGLIST (which contains all the thing list manipulating functions), I
  31. >must define a Thing.
  32.  
  33. >Which I did. But this Thing (as stated before) has a THINGLIST member in it.
  34. >Which is full of things, which are full of thinglists, which are full of...
  35.  
  36.  
  37. >Anyways; is it possible for me to do something like this? In the end I want a
  38. >bunch of things dynamically created at run time, and able to be placed in a
  39. >list of things. I also want to let each of the things in that list to be able
  40. >to look at all the other things in that list, so that they might (for instance)
  41. >place data in a selected thing's input buffer.
  42.  
  43. >I've got code I could post to show you where I'm at; so if you could at all
  44. >help me (PLEASE!) email me at
  45.  
  46. >            pfennig@alaska.net
  47.  
  48. >    (That's my private account. I'm using my rock-slow university account
  49. >with a crappy newsreader I never use right now)
  50.  
  51. >THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU in advance.
  52.  
  53.  
  54. Use a forward declaration like :
  55.  
  56.  
  57. class Thing;
  58.  
  59. class ThingsList {
  60.     .
  61.     .
  62.     .
  63. };
  64.  
  65. class Thing {
  66.     .
  67.     .
  68.     .
  69. };
  70.  
  71.  
  72. Or, if it does not fit your needs, try the opposite : make a forward
  73. declaration of ThingsList instead of the Thing.
  74.  
  75.  
  76. Adi
  77. NY
  78.  
  79.  
  80.